<template>
	<view>
		<view v-for="(item,index) in apply_list" :key="item.id" class="truck_item">
			<view class="div_item">
				<view>驾驶员<span>{{item.flight.driver || '--'}}</span></view>
				<view>电话 <span>{{item.flight.driverTel || '--'}}</span></view>
			</view>
			<view class="div_item">
				<view>线路<span>{{item.flight.addrfrom || '--'}} → {{item.flight.addrto || '--'}}</span></view>
				<!-- <view>装车单号<span>{{item.loadno || '--'}}</span></view> -->
			</view>
			<view class="div_item">
				<view>收款人<span>{{item.bank.username || '--'}}</span></view>
				<view>账号<span>{{item.bank_code || '--'}}</span></view>
			</view>
			<view class="div_item">
				<view>开户行<span>{{item.bank.bank_name || '--'}}{{item.bank.bank_deposit || '--'}}</span></view>
				<!-- <view>账号<span>{{item.bank_code || '--'}}</span></view> -->
			</view>

			<view class="div_item">
				<view>当前状态<span>{{ getStatusTxt(item.status)}}</span></view>
				<!-- <view>账号<span>{{item.bank_code || '--'}}</span></view> -->
			</view>

			<!-- 底部操作菜单 -->
			<view class="op_menu_div">
				<view class="btn_share" @click.stop="onApply(item)">重新申请</view>
			</view>

		</view>

		<view v-if="!apply_list || apply_list.length <= 0"
			style="width: 100vw;height: 80vh;text-align: center;margin: 38vh 0 0 0;">
			暂无数据~
		</view>

	</view>
</template>

<script>
	import { getStatusTxt } from '@/util/util.js'
	export default {
		data() {
			return {
				apply_list: [], // 运费申请列表
			}
		},

		mounted() {
			let that = this
			this.getApplyList()

			// 事件总线:收到重新申请车费的消息
			uni.$on('onReApplyFreight', data => {
				console.log('监听到事件来自onReApplyFreight,携带参数 data =', data);
				that.getApplyList()
			})
		},

		methods: {

			// 申请车费 申请状态 1=审核中 2=已拒绝 3=已打款 4=待财务审核 5=待打款
			onApply(item) {
				if (item.status != '2') {
					uni.showToast({ title: '当前状态不能重新申请', icon: 'none' })
					return
				}
				// uni.showToast({ title: '申请车费开发中', icon: 'none' })
				uni.setStorageSync('apply_info', JSON.stringify(item))
				uni.navigateTo({
					url: `/pages/i2/apply_freight/apply_freight_2?apply=${JSON.stringify(item)}`
				})
			},

			async getApplyList() {
				// let uinfo = this.$getUserInfo()
				// memberid: '200017',
				// accountid: '7789925a89204c38a0c1f9e73cbdc293',
				let res = await this.$rqt.Freight_lists({})
				console.log('getApplyList.res =', res);
				if (res.code == 1) {
					this.apply_list = res.data
				} else {
					this.$toast(res.msg)
				}
			},

			getStatusTxt(status) {
				return getStatusTxt(status)
			},

		}
	}
</script>

<style scoped>
	.truck_item {
		margin: 20rpx;
		border: solid 1rpx rgba(0, 0, 0, 0.15);
		border-radius: 10rpx;
	}

	.div_item {
		display: flex;
		align-items: center;
		justify-content: space-between;
		margin: 14rpx 14rpx 0 14rpx;
		font-size: 28rpx;
	}

	span {
		/* display: block; */
		margin: 0 0 0 10rpx;
		color: #1890FF;
		font-size: 26rpx;
	}

	.op_menu_div {
		display: flex;
		justify-content: flex-end;
		padding: 14rpx;
	}

	.btn_share {
		background-color: #1890FF;
		width: 118rpx;
		height: 52rpx;
		line-height: 52rpx;
		text-align: center;
		font-size: 24rpx;
		color: white;
		border-radius: 4rpx;
		margin: 0 0 0 12rpx;
	}
</style>